<!DOCTYPE html>
<html>
<head>
    <title>Nuclear Energy Level Diagram</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        canvas {
            border: 1px solid #ccc;
            background-color: #fff;
        }
    </style>
</head>
<body>
    <canvas id="physicsCanvas" width="450" height="400"></canvas>
    <script>
        const canvas = document.getElementById('physicsCanvas');
        const ctx = canvas.getContext('2d');

        // Set styles
        ctx.strokeStyle = 'black';
        ctx.fillStyle = 'black';
        ctx.lineWidth = 2;
        const mainFont = "28px 'Times New Roman'";
        const supFont = "20px 'Times New Roman'";

        // --- Draw the main container box ---
        ctx.strokeRect(50, 40, 350, 280);

        // --- Draw the column headers ---
        ctx.font = mainFont;
        ctx.textAlign = 'center';
        ctx.textBaseline = 'middle';

        // 'E' for Energy
        ctx.fillText("E", 100, 85);

        // 'J^P' for Spin-Parity
        ctx.fillText("J", 320, 85);
        ctx.font = supFont;
        ctx.fillText("P", 335, 78); // Superscript 'P'

        // --- Draw the energy levels ---
        // Level 1: 3.55 MeV, 4+
        const y1 = 130;
        ctx.font = mainFont;
        ctx.textAlign = 'right';
        ctx.fillText("3.55", 135, y1);
        ctx.beginPath();
        ctx.moveTo(150, y1);
        ctx.lineTo(300, y1);
        ctx.stroke();
        ctx.textAlign = 'center';
        ctx.fillText("4", 320, y1);
        ctx.font = supFont;
        ctx.fillText("+", 335, y1 - 7); // Superscript '+'

        // Level 2: 1.98 MeV, 2+
        const y2 = 200;
        ctx.font = mainFont;
        ctx.textAlign = 'right';
        ctx.fillText("1.98", 135, y2);
        ctx.beginPath();
        ctx.moveTo(150, y2);
        ctx.lineTo(300, y2);
        ctx.stroke();
        ctx.textAlign = 'center';
        ctx.fillText("2", 320, y2);
        ctx.font = supFont;
        ctx.fillText("+", 335, y2 - 7); // Superscript '+'
        
        // Level 3: 0 MeV, 0+ (Ground State)
        const y3 = 270;
        ctx.font = mainFont;
        ctx.textAlign = 'right';
        ctx.fillText("0", 135, y3);
        ctx.beginPath();
        ctx.moveTo(150, y3);
        ctx.lineTo(300, y3);
        ctx.stroke();
        ctx.textAlign = 'center';
        ctx.fillText("0", 320, y3);
        ctx.font = supFont;
        ctx.fillText("+", 335, y3 - 7); // Superscript '+'

        // --- Draw the Isotope Label ---
        ctx.font = mainFont;
        ctx.textAlign = 'center';
        ctx.fillText("O", 230, 300);
        ctx.font = supFont;
        ctx.fillText("18", 218, 293); // Superscript '18'

        // --- Draw the Figure Caption ---
        ctx.font = mainFont;
        ctx.textAlign = 'center';
        ctx.fillText("Fig. 2.19", 225, 370);

    </script>
</body>
</html>